#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define M 100005
int n,m,L,V,ans;
int a[M],v[M],d[M];
int p[M];
int pos[N],pr[N];
struct node{
    int l;
    int r;
}c[M];int cnt;
bool cmp(node x,node y){
    if(x.l==y.l) return x.r<y.r;
    else return x.l<y.l;
}

void init(){
    for(int i=1;i<=cnt+1;i++) c[i].l=c[i].r=0;
    memset(p,0,sizeof(p));
    cnt=0;
    memset(pos,0,sizeof(pos));
    memset(pr,0,sizeof(pr));
    ans=0;
}
void solve(){
    bool flag0=1;
    scanf("%d%d%d%d",&n,&m,&L,&V);
    L++;
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&d[i],&v[i],&a[i]);
        d[i]++;
      //  if(a[i]==0) flag0=0;
    }
    for(int i=1;i<=m;i++) {
        scanf("%d",&p[i]);
        p[i]++;
        pos[p[i]]=1;
    }
    sort(p+1,p+m+1);
    for(int i=2;i<=L;i++) pos[i]+=pos[i-1];
    for(int i=1;i<=L;i++) {
            if(pos[i]==pos[i-1]+1) pr[i]=i;
            else pr[i]=pr[i-1];
    }
    //for(int i=1;i<=L;i++) {
    //    cout<<i<<" "<<pr[i]<<" "<<pos[i]<<endl;
    //}
    for(int i=1;i<=n;i++) {
        if(a[i]==0) {
            if(v[i]<=V) continue;
            else if(d[i]>p[m]) continue;
            ans++;
            c[++cnt].r=L,c[cnt].l=d[i];
        }
        if(a[i]>0){
            if(p[m]<d[i]) continue;
            if(p[m]>=d[i]&&(v[i]*v[i]+2*a[i]*(p[m]-d[i])>V*V)) {
                ans++;
                int dx=floor((V*V-v[i]*v[i])*1.0/2/a[i]);
                c[++cnt].l=d[i]+dx+1,c[cnt].r=L;
            }
        }
        if(a[i]<0) {
            if(v[i]<=V) continue;
            else if(d[i]>p[m]) continue;
            int dx=floor((V*V-v[i]*v[i])*1.0/2/a[i]);
            if(dx*2*a[i]==(V*V-v[i]*v[i])) dx--;
            if(pos[d[i]+dx]==pos[d[i]]) continue;
            else {
                ans++;
                c[++cnt].l=d[i],c[cnt].r=d[i]+dx;
            }
        }
    }
    sort(c+1,c+cnt+1,cmp);
    if(ans==0) {
        cout<<"0 "<<m<<endl;
        return ;
    }

   //for(int i=1;i<=cnt;i++) {
   //     cout<<i<<" "<<c[i].l<<" "<<c[i].r<<endl;
   // }
    int now=0,cntt=1;
    now=pr[c[1].r];
    for(int i=2;i<=cnt;i++) {
        if(c[i].l<=now&&c[i].r>=now) continue;
        else {
            cntt++;
            now=pr[c[i].r];
        }
    }
    cout<<ans<<" ";cout<<m-cntt<<endl;
    return ;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        solve();init();
    }
    return 0;
}
